Modernize C# code snippets - System/U*, System/V*, System/W* - #12974
Draft
gewarren wants to merge 9 commits into
Draft
Modernize C# code snippets - System/U*, System/V*, System/W*#12974gewarren wants to merge 9 commits into
gewarren wants to merge 9 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes a large set of .NET API documentation C# snippets in the System/U*, System/V*, and System/W* areas, aligning them with newer C# idioms as part of issue #12713.
Changes:
- Updated snippets to modern C# syntax (target-typed
new, expression-bodied members, switch expressions, and string interpolation). - Removed unused
usingdirectives and normalized formatting/indentation. - Refreshed several snippet implementations to use updated patterns (for example, object initializers and simplified
Console.WriteLineformatting).
Reviewed changes
Copilot reviewed 77 out of 78 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| snippets/csharp/System/WeakReference/Overview/program.cs | Modern C# syntax and formatting in WeakReference cache example. |
| snippets/csharp/System/Version/TryParse/tryparse1.cs | Modernized formatting and string interpolation in TryParse example. |
| snippets/csharp/System/Version/Parse/parse1.cs | Modernized formatting and string interpolation in Parse example. |
| snippets/csharp/System/Version/Overview/GettingVersions1.cs | Removed unused using and kept snippet minimal/clean. |
| snippets/csharp/System/Version/Overview/example1.cs | Simplified attribute usage and modernized output formatting. |
| snippets/csharp/System/Version/Overview/currentassem.cs | Modernized formatting and string interpolation. |
| snippets/csharp/System/Version/Overview/currentapp.cs | Modernized formatting and string interpolation. |
| snippets/csharp/System/Version/Overview/comparisons2.cs | Reformatted enum and simplified method body/output. |
| snippets/csharp/System/Version/Overview/comparisons1.cs | Modernized control flow using switch expression. |
| snippets/csharp/System/Version/.ctor/rev.cs | Target-typed new and formatting normalization. |
| snippets/csharp/System/ValueType/ToString/ToString2.cs | Modernized types (string) and simplified overrides. |
| snippets/csharp/System/ValueType/Overview/example1.cs | Modernized formatting and simplified helper methods. |
| snippets/csharp/System/ValueType/Equals/source.cs | Reformatted code and simplified GetHashCode implementation. |
| snippets/csharp/System/UriBuilder/Query/main.cs | Removed unused usings and modernized UriBuilder construction. |
| snippets/csharp/System/UriBuilder/Fragment/source.cs | Modernized construction using object initializer; removed unused usings. |
| snippets/csharp/System/UriBuilder/.ctor/source3.cs | Modernized formatting and UriBuilder construction. |
| snippets/csharp/System/UriBuilder/.ctor/source2.cs | Modernized formatting and UriBuilder construction. |
| snippets/csharp/System/UriBuilder/.ctor/source1.cs | Modernized formatting and UriBuilder construction. |
| snippets/csharp/System/UriBuilder/.ctor/source.cs | Modernized formatting and UriBuilder construction. |
| snippets/csharp/System/Uri/Scheme/source.cs | Removed unused usings and modernized Uri construction. |
| snippets/csharp/System/Uri/Port/source.cs | Removed unused usings and modernized Uri construction. |
| snippets/csharp/System/Uri/PathAndQuery/source.cs | Removed unused usings and modernized Uri construction/output. |
| snippets/csharp/System/Uri/Overview/source.cs | Modernized Uri construction and expanded/normalized sample output formatting. |
| snippets/csharp/System/Uri/HostComparison/source.cs | Modernized Uri constructions in host comparison examples. |
| snippets/csharp/System/Uri/Host/source.cs | Removed unused usings and modernized Uri construction. |
| snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs | Modernized many snippet sections (interpolation, target-typed new, formatting). |
| snippets/csharp/System/Uri/CheckHostName/source.cs | Removed unused usings and modernized formatting/indentation. |
| snippets/csharp/System/Uri/Authority/source.cs | Removed unused usings and modernized Uri construction/output. |
| snippets/csharp/System/Uri/AbsoluteUri/source.cs | Removed unused usings and modernized Uri construction. |
| snippets/csharp/System/Uri/AbsolutePath/source.cs | Removed unused usings and modernized Uri construction. |
| snippets/csharp/System/Uri/.ctor/source2.cs | Removed unused usings and modernized formatting/indentation. |
| snippets/csharp/System/Uri/.ctor/source.cs | Removed unused usings and modernized formatting/indentation. |
| snippets/csharp/System/Uri/.ctor/nclurienhancements.cs | Modernized formatting and Uri constructions across snippets. |
| snippets/csharp/System/UnauthorizedAccessException/Overview/withio.cs | Modernized formatting and simplified object creation syntax. |
| snippets/csharp/System/UIntPtr/Subtract/subtract1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UIntPtr/op_Addition/op_subtraction1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UIntPtr/op_Addition/op_addition1.cs | Modernized formatting for operator-based pointer arithmetic example. |
| snippets/csharp/System/UIntPtr/Add/add1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt64/TryParse/tryparse2.cs | Modernized formatting and updated to keyword aliases (ulong). |
| snippets/csharp/System/UInt64/TryParse/tryparse1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt64/ToString/tostring4.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt64/ToString/tostring3.cs | Modernized formatting and removed unused using. |
| snippets/csharp/System/UInt64/ToString/tostring2.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt64/ToString/tostring1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt64/Parse/parseex4.cs | Modernized formatting, parsing calls, and string interpolation output. |
| snippets/csharp/System/UInt64/Parse/parseex2.cs | Modernized formatting and string interpolation output for parse attempts. |
| snippets/csharp/System/UInt64/Parse/parse1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt64/MaxValue/MaxValue1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt64/Equals/uint64_equals.cs | Modernized formatting, keyword aliases, and output strings. |
| snippets/csharp/System/UInt64/Equals/equalsoverl.cs | Modernized formatting and condensed helper output logic. |
| snippets/csharp/System/UInt64/Equals/equals1.cs | Modernized formatting, keyword aliases, and output strings. |
| snippets/csharp/System/UInt64/CompareTo/source.cs | Large formatting modernization and updated parsing/ToString patterns. |
| snippets/csharp/System/UInt32/ToString/tostring4.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt32/ToString/tostring3.cs | Modernized formatting and removed unused using. |
| snippets/csharp/System/UInt32/ToString/tostring2.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt32/ToString/tostring1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt32/Parse/parseex4.cs | Modernized formatting, parsing calls, and string interpolation output. |
| snippets/csharp/System/UInt32/Parse/parseex2.cs | Modernized formatting and string interpolation output for parse attempts. |
| snippets/csharp/System/UInt32/Parse/parse1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt32/MaxValue/MaxValue1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt32/Equals/uint32_equals.cs | Modernized formatting and exception output string interpolation. |
| snippets/csharp/System/UInt32/Equals/equalsoverl.cs | Modernized formatting and condensed helper output logic. |
| snippets/csharp/System/UInt32/CompareTo/source.cs | Large formatting modernization and updated parsing/ToString patterns. |
| snippets/csharp/System/UInt16/TryParse/tryparse21.cs | Modernized formatting and updated to keyword aliases. |
| snippets/csharp/System/UInt16/TryParse/tryparse2.cs | Modernized formatting and updated to keyword aliases. |
| snippets/csharp/System/UInt16/TryParse/tryparse11.cs | Modernized formatting and updated to keyword aliases. |
| snippets/csharp/System/UInt16/ToString/tostring4.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt16/ToString/tostring3.cs | Modernized formatting and removed unused using. |
| snippets/csharp/System/UInt16/ToString/tostring2.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt16/ToString/tostring1.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt16/Parse/parseex5.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt16/Parse/parseex4.cs | Modernized formatting, parsing calls, and string interpolation output. |
| snippets/csharp/System/UInt16/Parse/parseex3.cs | Modernized formatting and string interpolation output. |
| snippets/csharp/System/UInt16/Parse/parseex2.cs | Modernized formatting and string interpolation output for parse attempts. |
| snippets/csharp/System/UInt16/MaxValue/MaxValue.cs | Modernized formatting; retained range-check pattern. |
| snippets/csharp/System/UInt16/Equals/uint16_equals.cs | Updated type aliases and modernized exception output formatting. |
| snippets/csharp/System/UInt16/Equals/equalsoverl.cs | Modernized formatting and condensed helper output logic. |
| snippets/csharp/System/UInt16/CompareTo/source.cs | Large formatting modernization and updated parsing/ToString patterns. |
Suppressed comments (1)
snippets/csharp/System/Version/Parse/parse1.cs:63
- The documented sample output has the same missing closing apostrophe as the code. After fixing the message format, update the output comment lines so they match the actual output.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ze-code-system-uv
…ze-code-system-uv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #12713.
Internal previews
Toggle expand/collapse
Note
This table shows the first 30 preview links (sorted alphabetically by file path) found in the OPS build report. For the full list, select OpenPublishing.Build Details within checks.